Skip to content

Conversation

@Hapsa21
Copy link
Contributor

@Hapsa21 Hapsa21 commented Nov 28, 2025

Description

This PR implements the missing is_square() method for LaurentSeries and LazyLaurentSeries elements. Previously, calling .is_square() on these series would raise an AttributeError.

The implementation follows the mathematical definition: a Laurent series $f = t^v \cdot u$ is a square if and only if:

  1. The valuation $v$ is even.
  2. The unit part $u$ is a square (in the underlying PowerSeriesRing or base ring).

Changes:

  • LaurentSeries: Implemented is_square by checking the valuation and delegating the unit check to the underlying PowerSeries logic.
  • LazyLaurentSeries: Implemented is_square to harmonize functionality, ensuring it handles unit shifts correctly before delegating to the lazy sqrt() method.

Both implementations support the root=True argument to return the square root when it exists.

Fixes

#41221

@mantepse
Copy link
Contributor

mantepse commented Dec 1, 2025

It would be great to harmonize with lazy Laurent series.

@Hapsa21
Copy link
Contributor Author

Hapsa21 commented Dec 1, 2025

It would be great to harmonize with lazy Laurent series.

done

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally do not have periods/full-stops at the end of input blocks. Once changed, I will set a positive review.

@tscrim
Copy link
Collaborator

tscrim commented Dec 3, 2025

Okay, LGTM.

(Mostly for @mantepse) At some point, we probably should figure out a way to combine stuff for both classes; perhaps some kind of mixin class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants